//! 数据生成器模块

pub mod name;
pub mod datetime;
pub mod address;
pub mod internet;
pub mod number;

use serde_json::Value;

/// 核心生成器 Trait
pub trait Generator: Send + Sync {
    fn generate(&self) -> Value;
}

/// UUID v4 生成器
pub fn uuid_v4() -> String {
    uuid::Uuid::new_v4().to_string()
}

/// 随机整数生成器
pub fn random_int(min: i32, max: i32) -> i32 {
    use rand::Rng;
    let mut rng = rand::thread_rng();
    rng.gen_range(min..=max)
}

/// 随机浮点数生成器
pub fn random_float(min: f64, max: f64) -> f64 {
    use rand::Rng;
    let mut rng = rand::thread_rng();
    rng.gen_range(min..=max)
}

/// 随机布尔值生成器
pub fn random_bool() -> bool {
    use rand::Rng;
    let mut rng = rand::thread_rng();
    rng.gen_bool(0.5)
}

/// 从数组中随机选择
pub fn random_choice<T: Clone>(choices: &[T]) -> T {
    use rand::seq::SliceRandom;
    let mut rng = rand::thread_rng();
    choices.choose(&mut rng).unwrap().clone()
}